package com.yancy.controller;

import com.yancy.entity.New;
import com.yancy.service.NewService;
import com.yancy.service.impl.NewServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @description:
 * @author: YancyZhang
 * @time: 2021/12/3 13:12
 */
@WebServlet("/getSingleNew")
public class GetSingleNew extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        NewService newService = new NewServiceImpl();
        New singleNew = newService.getSingleNew(id);
        req.setAttribute("singleNew",singleNew);
        req.getRequestDispatcher("singleNew.jsp").forward(req,resp);
    }
}